package Sessions;

import java.util.ArrayList;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.jboss.ejb3.annotation.RemoteBinding;

import EntityBeans.Abilita;

/**
 * Session Bean implementation class RichiesteAbilitaAdminSession
 */
@Stateless
@RemoteBinding(jndiBinding="RichiesteAbilitaAdminSessionRemote")
public class RichiesteAbilitaAdminSession implements RichiesteAbilitaAdminSessionRemote {
	@PersistenceContext(unitName="swimv2")
	private EntityManager manager;
    public RichiesteAbilitaAdminSession() {
        // TODO Auto-generated constructor stub
    }

	@Override
	public ArrayList<Abilita> richiesteAbilita() {
		boolean valore=false;
		String s = "FROM Abilita a WHERE a.accettata=:valore";
		Query q = manager.createQuery(s);
		q.setParameter("valore", valore);
		@SuppressWarnings("unchecked")
		ArrayList<Abilita> abilitaRichieste = (ArrayList<Abilita>) q.getResultList();
		if(abilitaRichieste == null || abilitaRichieste.size() == 0)
			return null;
		else 
			return abilitaRichieste;
					
	}

}
